package com.none.staff.view.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class HomeFragmentPagerAdapter extends FragmentPagerAdapter {


    private List<String> titles;

    private List<Fragment> fragmentList;

    public HomeFragmentPagerAdapter(FragmentManager fm,List<String> titles, List<Fragment> fragmentList) {
        super(fm);
        this.fragmentList = fragmentList;
        this.titles =titles;
    }

    public void setFragmentList(List<Fragment> fragmentAddList) {
        this.fragmentList.addAll(fragmentAddList);
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int i) {
        return fragmentList.get(i);
    }

    @Override
    public int getCount() {
        if (fragmentList == null || fragmentList.size() == 0) {
            return 0;
        }
        return fragmentList.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}
